//
//  MIDIbroadcastController.m
//  迷笛
//
//  Created by . on 2018/9/17.
//  Copyright © 2018年 🍃🌺🌺🍃. All rights reserved.
//

#import "MIDIbroadcastController.h"

@interface MIDIbroadcastController ()

@property(nonatomic,strong)UIImageView * miusview;
@property(nonatomic,strong)UIImageView * miusiamge;
@property(nonatomic,strong)UILabel * name;
@property(nonatomic,strong)UILabel * singer;
@property(nonatomic,strong)UIButton * love;
@property(nonatomic,strong)UIButton * Under;
@property(nonatomic,strong)UIButton * topp;
@property(nonatomic,strong)UIButton * stop;
@property(nonatomic,strong)UILabel * start;
@property(nonatomic,strong)UILabel * end;

@end

@implementation MIDIbroadcastController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor =[UIColor colorWithHexString:@"#1B212F"];
    UIBarButtonItem *leftBarItem = [[UIBarButtonItem alloc] initWithTitle:nil style:UIBarButtonItemStylePlain target:self action:@selector(Block:)];
    self.navigationItem.leftBarButtonItem = leftBarItem;
    
    [self.navigationItem.leftBarButtonItem setImage:[[UIImage imageNamed:@"后退"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [self homeUI];
}

//视图将要出现时（导航颜色字体颜色）
- (void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = YES;
    self.navigationController.navigationBar.translucent = NO;//Bar的模糊效果，默认为YES（导航颜色不纯时用此方法）

//    self.navigationController.navigationBar.hidden = YES;//隐藏导航
    
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"#1B212F"];
    self.title = @"音乐推荐";
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#FFFFFF"],NSFontAttributeName : [UIFont fontWithName:@"Helvetica-Bold" size:WidthScale(17)]}];
    //    去掉导航黑线
    UIImage *img = [UIImage imageNamed:@""];
    [self.navigationController.navigationBar setBackgroundImage:img  forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
}
// 返回上一级
-(void)Block:(UIButton * )sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)homeUI
{
    [self.view addSubview:self.miusview];
    [self.miusview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(kDevice_Is_iPhoneX?HeighX(157):WidthScale(60));
        make.centerX.equalTo(self.view);
        make.width.mas_offset(WidthScale(269));
        make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(269):WidthScale(269));
    }];
    [self.miusview addSubview:self.miusiamge];
    [self.miusiamge mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.miusview);
        make.centerX.equalTo(self.miusview);
        make.width.mas_offset(WidthScale(151));
        make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(151):HeightScale(151));
    }];
    [self.view addSubview:self.name];
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.miusview.mas_bottom).offset(WidthScale(50));
        make.left.mas_offset(WidthScale(20));
        [self.name setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    }];
    [self.view addSubview:self.name];
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.miusview.mas_bottom).offset(WidthScale(50));
        make.left.mas_offset(WidthScale(20));
        [self.name setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    }];
    [self.view addSubview:self.singer];
    [self.singer mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.name.mas_bottom).offset(WidthScale(10));
        make.left.equalTo(self.name);
        [self.singer setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    }];
    
    [self.view addSubview:self.start];
    [self.start mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.singer.mas_bottom).offset(WidthScale(40));
        make.left.mas_offset(WidthScale(20));
        [self.start setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    }];
    [self.view addSubview:self.end];
    [self.end mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.start);
        make.right.mas_offset(WidthScale(-20));
        [self.end setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    }];
    
    [self.view addSubview:self.love];
    [self.love mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.name);
        make.right.mas_offset(WidthScale(-20));
        make.width.mas_offset(WidthScale(23));
        make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(23):HeightScale(23));
    }];
    [self.view addSubview:self.stop];
    [self.stop mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.bottom.mas_offset(kDevice_Is_iPhoneX?WidthScale(-93):WidthScale(-49));
        make.width.mas_offset(WidthScale(52));
        make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(52):HeightScale(52));
    }];
    [self.view addSubview:self.topp];
    [self.topp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.stop);
//        make.right.equalTo(self.stop.mas_left).offset(WidthScale(40));
        make.right.equalTo(self.stop.mas_left).offset(WidthScale(-40));

        make.width.mas_offset(WidthScale(33));
        make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(33):HeightScale(33));
    }];
    [self.view addSubview:self.Under];
    [self.Under mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.centerY.equalTo(self.stop);
        make.left.equalTo(self.stop.mas_right).offset(WidthScale(40));
        make.width.mas_offset(WidthScale(33));
        make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(33):HeightScale(33));
    }];
}

-(UIImageView *)miusview
{
    if (!_miusview)
    {
        _miusview =[[UIImageView alloc]init];
        _miusview.backgroundColor =[UIColor redColor];
        _miusview.image =[UIImage imageNamed:@"diepian"];;

        _miusview.layer.masksToBounds=YES;
        //图片自身宽度除以2可设置为圆形
        [_miusview.layer setCornerRadius:WidthScale(134.5)]; //设置矩圆角半径
    }
    return _miusview;
}
-(UIImageView *)miusiamge
{
    if (!_miusiamge)
    {
        _miusiamge =[[UIImageView alloc]init];
        _miusiamge.image = [UIImage imageNamed:@""];
        _miusiamge.layer.masksToBounds = YES;
        [_miusiamge.layer setCornerRadius:WidthScale(75.75)]; //设置矩圆角半径
    }
    return _miusiamge;
}
-(UILabel *)name
{
    if (!_name)
    {
        _name =[[UILabel alloc]init];
        _name.text = @"如果我不能看到那一天";
        _name.font =[UIFont systemFontOfSize:WidthScale(16)];
        _name.textColor = [UIColor colorWithHexString:@"#FFFFFF"];
//        [self.ID setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    }
    return _name;
}
-(UILabel *)singer
{
    if (!_singer)
    {
        _singer =[[UILabel alloc]init];
        _singer.text = @"天堂乐队";
        _singer.font =[UIFont systemFontOfSize:WidthScale(12)];
        _singer.textColor = [UIColor colorWithHexString:@"#999999"];
        //        [self.ID setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    }
    return _singer;
}
-(UIButton *)love
{
    if (!_love)
    {
        _love =[[UIButton alloc]init];
        [_love setBackgroundImage:[UIImage imageNamed:@"xin"] forState:0];
        [_love addTarget:self action:@selector(Xin:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _love;
}
-(UIButton *)Under
{
    if (!_Under)
    {
        _Under =[[UIButton alloc]init];
//        [_Under setBackgroundColor:[UIColor orangeColor]];
        [_Under setBackgroundImage:[UIImage imageNamed:@"qianjin"] forState:0];
        
    }
    return _Under;
}
-(UIButton *)stop
{
    if (!_stop)
    {
        _stop =[[UIButton alloc]init];
//        [_stop setBackgroundColor:[UIColor blueColor]];
        [_stop setBackgroundImage:[UIImage imageNamed:@"bofang"] forState:0];
        [_stop addTarget:self action:@selector(stop:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _stop;
}
-(UIButton *)topp
{
    if (!_topp)
    {
        _topp =[[UIButton alloc]init];
//        [_topp setBackgroundColor:[UIColor redColor]];
        [_topp setBackgroundImage:[UIImage imageNamed:@"houtui"] forState:0];

    }
    return _topp;
}
-(UILabel *)start
{
    if (!_start)
    {
        _start =[[UILabel alloc]init];
        _start.text = @"00:00";
        _start.textColor = [UIColor colorWithHexString:@"#FFFFFF"];
        _start.font =[UIFont systemFontOfSize:WidthScale(12)];
    }
    return _start;
}
-(UILabel *)end
{
    if (!_end)
    {
        _end =[[UILabel alloc]init];
        _end.text = @"04:30";
        _end.textColor = [UIColor colorWithHexString:@"#FFFFFF"];
        _end.font =[UIFont systemFontOfSize:WidthScale(12)];
    }
    return _end;
}
-(void)Xin:(UIButton * )sender
{
    sender.selected=!sender.selected;//每次点击都改变按钮的状态
    if (sender.selected == YES)
    {
        //        第一次点击为蓝色（关注）
        
        [sender setBackgroundImage:[UIImage imageNamed:@"xuanzhong-xin"] forState:0];
        NSLog(@"已关注");
    }
    else
    {
            //        第二次点击为红色（如取消关注）
        [sender setBackgroundImage:[UIImage imageNamed:@"xin"] forState:0];
            NSLog(@"取消关注");
    }
}
-(void)stop:(UIButton * )sender
{
    sender.selected=!sender.selected;//每次点击都改变按钮的状态
    if (sender.selected == YES)
    {
        //        第一次点击为蓝色（关注）
        
        [sender setBackgroundImage:[UIImage imageNamed:@"zanting"] forState:0];
        NSLog(@"播放");
    }
    else
    {
        //        第二次点击为红色（如取消关注）
        [sender setBackgroundImage:[UIImage imageNamed:@"bofang"] forState:0];
        NSLog(@"暂停");
    }
}

@end
